package com.dkd.manage.service.Impl;

import com.dkd.manage.mapper.VmTypeMapper;
import com.dkd.manage.pojo.dto.VmTypeQueryListDto;
import com.dkd.manage.pojo.entity.VmType;
import com.dkd.manage.result.PageResult;
import com.dkd.manage.service.VmTypeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class VmTypeServiceImpl implements VmTypeService {


    @Autowired
    private VmTypeMapper vmTypeMapper;

    /**
     * 分页查询设备类型列表
     * @param vmTypeQueryListDto
     * @return
     */
    @Override
    public PageResult<VmType> list(VmTypeQueryListDto vmTypeQueryListDto) {
        //开启分页
        PageHelper.startPage(vmTypeQueryListDto.getPageNum(), vmTypeQueryListDto.getPageSize());
        //查询点位列表
        List<VmType> vmTypeList =  vmTypeMapper.list(vmTypeQueryListDto);
        //获取分页详情对象
        PageInfo<VmType> pageInfo = new PageInfo<VmType>(vmTypeList);
        //封装数据返回
        return new PageResult<>(pageInfo.getTotal(), pageInfo.getList());
    }


    /**
     * 新增设备类型
     * @param vmType
     * @return
     */
    @Override
    public Integer add(VmType vmType) {
        return vmTypeMapper.add(vmType);
    }

    /**
     * 根据id查询设备
     * @param id
     * @return
     */
    @Override
    public VmType getVmTypeById(Long id) {
        return vmTypeMapper.getVmTypeById(id);
    }

    /**
     * 修改设备类型
     * @param vmType
     * @return
     */
    @Override
    public Integer edit(VmType vmType) {
        return vmTypeMapper.edit(vmType);
    }

    /**
     * 根据id删除设备类型
     * @param ids
     * @return
     */
    @Override
    public Integer deleteVmTypeById(Long[] ids) {

        return vmTypeMapper.deleteVmTypeById(ids);
    }
}
